<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
    Prabhat, initial page, CSS and W3C validation
    Usman, added Javascript
    02/03/11 Prabhat, reviewed Javascript
    Xxx, made page dynamic JSP
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
        <title>Net-Chat:Register</title>
        <link rel="stylesheet" type="text/css" href="../style/common.css"></link>
        <script type="text/javascript" src="../js/common.js"></script>
        <script type="text/javascript">
            function validate() {
                var sFname = document.getElementById("fname");
                var sLname = document.getElementById("lname");
                var sPassword = document.getElementById("password");
                var scPassword = document.getElementById("confirmpassword");

                if (isValidName(sFname.value, "first name")) {
                    if (isValidName(sLname.value, "last name")) {
                        if (isValidPassword(sPassword.value)) {

                            if (scPassword.value != sPassword.value) {
                                alert("Passwords do not match");
                                scPassword.focus();
                            }
                            else {
                                //if form is valid
                                alert("Hah, you should see what's next in Stage 2");
                                // TODO: need to post for in stage 2
                            }
                        }
                        else sPassword.focus();
                    }
                    else sLname.focus();
                }
                else sFname.focus();
                
                return false;
            }
        </script>
    </head>
    <body>
        <div id="container">
            <div id="top">
                <h1>Net-Chat</h1>
            </div>
            <div id="leftnav">
                <p>
                    New user registers on this page. Upon successful registration, a user ID is given to the user which is used to login.
                </p>
            </div>
            <div id="content">
                <h2>Register</h2>
                <form action="" method="post" onsubmit="return validate()">
                    <p>
                        <label class="w120" for="fname">First name: </label>
                        <input type="text" name="fname" id="fname" />
                        <br />
                        <label class="w120" for="lname">Last name: </label>
                        <input type="text" name="lname" id="lname" />
                        <br />
                        <label class="w120" for="password">Password: </label>
                        <input type="password" name="password" id="password" />
                        <br />
                        <label class="w120" for="confirmpassword">Confirm Password: </label>
                        <input type="password" name="confirmpassword" id="confirmpassword" />
                    </p>
                    <p>
                        <input type="submit" name="register" id="register" value="register" />
                    </p>
                </form>
            </div>
            <div id="footer">
                <div class="alignleft">Author: Totoo, Usman</div>
                <div class="alignright">Network Applications</div>
                <div class="clr"></div>
            </div>
        </div>
        <p class="center">
            <a href="http://validator.w3.org/check?uri=referer">
                <img class="w3img" src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" />
            </a>
            <a href="http://jigsaw.w3.org/css-validator/check/referer">
                <img class="w3img" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" />
            </a>
        </p>
    </body>
</html>